module.exports = function (plop)  {
  plop.setGenerator('module', {
    description: '创建新的业务模块',
    prompts: [
      { type: 'input', name: 'name', message: '模块名称 (如 user):' },
    ],
    actions: [
      {
        type: 'add',
        path: 'src/controllers/{{dashCase name}}.controller.ts',
        templateFile: 'plop-template/module/controller.ts.hbs',
      },
      {
        type: 'add',
        path: 'src/services/{{dashCase name}}.service.ts',
        templateFile: 'plop-template/module/service.ts.hbs',
      },
      {
        type: 'add',
        path: 'src/dtos/{{dashCase name}}.dto.ts',
        templateFile: 'plop-template/dto/dto.ts.hbs',
      },
      {
        type: 'add',
        path: 'src/interfaces/{{dashCase name}}.interface.ts',
        templateFile: 'plop-template/interface/interface.ts.hbs',
      },
      {
        type: 'append',
        path: 'src/dtos/index.ts',
        pattern: /\/\* PLOP_INJECT_IMPORT \*\//,
        template: `export * from '@dtos/{{dashCase name}}.dto';`,
      },
      {
        type: 'append',
        path: 'src/interfaces/index.ts',
        pattern: /\/\* PLOP_INJECT_IMPORT \*\//,
        template: `export type * from './{{dashCase name}}.interface';`,
      },
    ],
  });

  plop.setGenerator('controller', {
    description: '创建新的控制器',
    prompts: [
      { type: 'input', name: 'name', message: '控制器名称 (如 user):' },
    ],
    actions: [
      {
        type: 'add',
        path: 'src/controllers/{{dashCase name}}.controller.ts',
        templateFile: 'plop-template/module/controller.ts.hbs',
      }
    ]
  });

  plop.setGenerator('service', {
    description: '创建新的服务',
    prompts: [
      { type: 'input', name: 'name', message: '服务名称 (如 user):' },
    ],
    actions: [
      {
        type: 'add',
        path: 'src/services/{{dashCase name}}.service.ts',
        templateFile: 'plop-template/module/service.ts.hbs',
      }
    ]
  })

  plop.setGenerator('dto', {
    description: '创建新的数据传输对象',
    prompts: [
      { type: 'input', name: 'name', message: 'DTO 名称 (如 user):' },
    ],
    actions: [
      {
        type: 'add',
        path: 'src/dtos/{{dashCase name}}.dto.ts',
        templateFile: 'plop-template/dto/dto.ts.hbs',
      },
      {
        type: 'append',
        path: 'src/dtos/index.ts',
        pattern: /\/\* PLOP_INJECT_IMPORT \*\//,
        template: `export * from '@dtos/{{dashCase name}}.dto';`,
      },
    ]
  })

  plop.setGenerator('interface', {
    description: '创建新的接口',
    prompts: [
      { type: 'input', name: 'name', message: '接口名称 (如 user):' },
    ],
    actions: [
      {
        type: 'add',
        path: 'src/interfaces/{{dashCase name}}.interface.ts',
        templateFile: 'plop-template/interface/interface.ts.hbs',
      },
      {
        type: 'append',
        path: 'src/interfaces/index.ts',
        pattern: /\/\* PLOP_INJECT_IMPORT \*\//,
        template: `export type * from './{{dashCase name}}.interface';`,
      },
    ]
  })
}
